#include "netproto_srv.h"

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

void sig_int( int nSignal )
{
  printf("signal: %d received\n",nSignal);
  //drpc_destroy_cli_handles();
  exit(1);
}

void sig_int2( int nSignal )
{
  printf("signal: %d received 2\n",nSignal);
}

void SetSignalHandle()
{
  signal(SIGINT,  sig_int);
  signal(SIGABRT, sig_int);
  signal(SIGBUS,  sig_int);
  signal(SIGALRM, sig_int);
  signal(SIGHUP,  sig_int);
  signal(SIGQUIT, sig_int);
  signal(SIGSEGV, sig_int);
  signal(SIGKILL, sig_int);
  signal(SIGTERM, sig_int);

  struct sigaction sa;
  sigemptyset(&sa.sa_mask);
  sa.sa_handler = SIG_IGN;
  sigaction( SIGPIPE, &sa, 0 );
  sigaction( SIGCHLD, &sa, 0 );

  sa.sa_handler = sig_int2; //SIG_IGN
  sa.sa_flags = 0;
  sigaction( SIGUSR1, &sa, 0 ); //dhcp ok will send this signal to me
  sigaction( 20, &sa, 0 );
  sigaction( 21, &sa, 0 );
  sigaction( 22, &sa, 0 );
  sigaction( 23, &sa, 0 );
}


int main()
{
  SetSignalHandle();
  drpc_netproto_srv_routine();
  //drpc_destroy_cli_handles();
  return 0;
}
